package com.bcx.crm.spring_boot.scheduled;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by ys on 2018/4/8.
 * 计划任务执行类
 */
@Service
public class ScheduledTaskService {
    private static final SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");

    @Scheduled(fixedRate = 500000)
    public void reportCurrentTime(){
        System.out.println("每隔500秒执行一次 : "+sdf.format(new Date()));
    }
    @Scheduled(cron = "0 07 11 ? * *")   //11点07分执行
    public void fixTimeExecution(){
        System.out.println("在指定时间--"+sdf.format(new Date())+"--执行");
    }
}
